```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java线程同步与锁机制深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-left: 4px solid #667eea;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(102, 126, 234, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight:hover:after {
            height: 100%;
        }
        .timeline-item:before {
            content: '';
            position: absolute;
            left: -38px;
            top: 0;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background-color: #667eea;
            border: 3px solid white;
            box-shadow: 0 0 0 2px #667eea;
        }
        .timeline-line:before {
            content: '';
            position: absolute;
            left: -31px;
            top: 0;
            bottom: 0;
            width: 2px;
            background-color: #e2e8f0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:py-32">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center text-center">
                <span class="inline-block px-3 py-1 mb-4 text-xs font-semibold tracking-wider text-purple-100 bg-black bg-opacity-20 rounded-full">JAVA并发编程</span>
                <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-6">Java线程同步与锁机制</h1>
                <p class="text-xl md:text-2xl text-purple-100 max-w-3xl leading-relaxed">
                    深入解析多线程环境下的共享资源安全访问机制，探索synchronized与ReentrantLock的核心实现原理
                </p>
                <div class="mt-10 flex space-x-4">
                    <a href="#content" class="px-6 py-3 bg-white text-purple-800 font-semibold rounded-lg shadow-md hover:bg-gray-100 transition duration-300">
                        <i class="fas fa-book-open mr-2"></i>开始阅读
                    </a>
                    <a href="#visualization" class="px-6 py-3 border-2 border-white text-white font-semibold rounded-lg hover:bg-white hover:text-purple-800 transition duration-300">
                        <i class="fas fa-project-diagram mr-2"></i>可视化图表
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl px-4 py-16" id="content">
        <!-- Introduction Card -->
        <div class="bg-white rounded-xl shadow-lg p-6 mb-12 card-hover transition duration-300">
            <div class="flex items-center mb-4">
                <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                    <i class="fas fa-lock text-purple-600"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">线程同步的核心概念</h2>
            </div>
            <p class="text-lg text-gray-700 mb-4">
                线程同步是多线程编程中非常关键的一部分，Java提供了多种锁机制来保证多个线程之间对共享资源的安全访问。锁机制有很多种类型，最常见的是<strong class="highlight font-semibold">悲观锁</strong>和<strong class="highlight font-semibold">乐观锁</strong>。
            </p>
            <div class="bg-blue-50 border-l-4 border-blue-400 p-4 rounded">
                <p class="text-blue-800 flex items-start">
                    <i class="fas fa-info-circle mt-1 mr-2 text-blue-500"></i>
                    <span>在多线程环境中，当多个线程访问共享资源时，如果没有适当的同步机制，可能会导致数据不一致、竞态条件等问题。Java的锁机制就是为了解决这些问题而设计的。</span>
                </p>
            </div>
        </div>

        <!-- Section 1: Basic Concepts -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-purple-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">1</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁的基本概念</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover transition duration-300">
                    <h3 class="text-xl font-semibold mb-4 text-purple-700 flex items-center">
                        <i class="fas fa-key mr-2"></i>Java中的锁机制
                    </h3>
                    <p class="text-gray-700 mb-4">
                        Java中的锁机制是用来控制并发访问共享资源的工具，目的是确保在多线程环境下线程的安全性。常见的锁有：
                    </p>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                            <span><code class="bg-gray-100 px-1 rounded">synchronized</code>锁：Java内置的同步机制，通过关键字<code class="bg-gray-100 px-1 rounded">synchronized</code>来控制对资源的访问。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-angle-right text-purple-500 mt-1 mr-2"></i>
                            <span><code class="bg-gray-100 px-1 rounded">ReentrantLock</code>锁：<code class="bg-gray-100 px-1 rounded">java.util.concurrent</code>包中提供的显式锁，功能更强大，支持公平锁、可中断等特性。</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card-hover transition duration-300">
                    <h3 class="text-xl font-semibold mb-4 text-blue-600 flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>锁的作用
                    </h3>
                    <p class="text-gray-700">
                        通过锁的机制，多个线程可以避免因为并发访问导致的数据不一致、竞态条件等问题。锁确保了同一时间只有一个线程可以访问临界区资源。
                    </p>
                    <div class="mt-4 p-4 bg-yellow-50 border-l-4 border-yellow-400 rounded">
                        <p class="text-yellow-800 flex items-start">
                            <i class="fas fa-exclamation-triangle mt-1 mr-2 text-yellow-500"></i>
                            <span>过度使用锁可能导致性能问题，因为线程获取锁失败时会进入阻塞状态，增加上下文切换的开销。</span>
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 2: Synchronized -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-blue-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">2</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">synchronized锁的实现</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 rounded">synchronized</code>是Java语言提供的最基本的同步机制，它用于确保某段代码在同一时刻只能由一个线程执行。可以通过加锁方法或加锁代码块的方式来实现。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-blue-700 flex items-center">
                                <i class="fas fa-code mr-2"></i>方法级锁示例
                            </h3>
                            <div class="code-block rounded-lg overflow-hidden">
                                <pre class="text-gray-300 p-4 text-sm"><code>public class SyncExample {
    public synchronized void syncMethod() {
        // 进入方法时锁住当前对象
        System.out.println("Thread " + 
            Thread.currentThread().getName() + 
            " is executing.");
    }
}</code></pre>
                            </div>
                            <p class="mt-3 text-gray-600 text-sm">
                                <i class="fas fa-info-circle text-blue-500 mr-1"></i> 当<code class="bg-gray-100 px-1 rounded">synchronized</code>修饰方法时，锁是作用于当前对象（非静态方法）或当前类的类锁（静态方法）。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-blue-700 flex items-center">
                                <i class="fas fa-code mr-2"></i>代码块锁示例
                            </h3>
                            <div class="code-block rounded-lg overflow-hidden">
                                <pre class="text-gray-300 p-4 text-sm"><code>public void syncBlock() {
    synchronized(this) {
        // 只有这部分代码在同一时刻能被一个线程执行
        System.out.println("Thread " + 
            Thread.currentThread().getName() + 
            " is executing.");
    }
}</code></pre>
                            </div>
                            <p class="mt-3 text-gray-600 text-sm">
                                <i class="fas fa-info-circle text-blue-500 mr-1"></i> <code class="bg-gray-100 px-1 rounded">synchronized</code>关键字也可以用于代码块，只有这部分代码会被加锁，效率更高。
                            </p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-gray-50 px-6 py-4 border-t border-gray-200">
                    <h3 class="text-lg font-semibold mb-2 text-gray-800">执行流程：</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>当线程执行到被<code class="bg-gray-100 px-1 rounded">synchronized</code>修饰的代码时，JVM会根据对象的锁标志位来判断该线程是否有权限进入。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>若锁未被其他线程持有，线程成功获得锁并进入执行阶段，执行完成后释放锁。</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>若锁已被其他线程持有，当前线程会进入阻塞状态，直到锁被释放。</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Section 3: Lock Object -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">3</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁对象和锁的内部实现</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        每个对象都可以作为锁使用。对于方法级别的锁，锁的对象是当前实例；对于静态方法，锁的对象是<code class="bg-gray-100 px-1 rounded">Class</code>对象。JVM通过对象头中的"Mark Word"字段来实现锁的标识。
                    </p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-6">
                        <pre class="text-gray-300 p-4 text-sm"><code>public class SyncExample {
    public synchronized void syncMethod() {
        // 当前对象的锁
        System.out.println("Thread " + 
            Thread.currentThread().getName() + 
            " is executing.");
    }
}</code></pre>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-indigo-700">对象锁</h3>
                            <p class="text-gray-700">
                                当一个线程调用<code class="bg-gray-100 px-1 rounded">synchronized</code>修饰的实例方法时，它会锁住当前实例对象。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-indigo-700">类锁</h3>
                            <p class="text-gray-700">
                                如果是静态方法或静态代码块，那么锁的是该类的<code class="bg-gray-100 px-1 rounded">Class</code>对象。
                            </p>
                        </div>
                    </div>
                    
                    <div class="mt-6 p-4 bg-blue-50 rounded-lg border border-blue-200">
                        <h3 class="text-lg font-semibold mb-2 text-blue-800">Mark Word详解</h3>
                        <p class="text-gray-700">
                            JVM通过对象头中的<code class="bg-gray-100 px-1 rounded">Mark Word</code>字段来标识当前对象的锁状态。<code class="bg-gray-100 px-1 rounded">Mark Word</code>包含了对象的锁信息，包括是否已经加锁、锁的类型、锁的持有者等。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 4: Lock Upgrade -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-teal-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">4</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁的升级机制</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        为了优化性能，Java的<code class="bg-gray-100 px-1 rounded">synchronized</code>锁实现了锁的升级机制。线程在执行时首先尝试获得偏向锁，然后是轻量级锁，最后如果竞争激烈则会升级为重量级锁。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-teal-700">偏向锁</h3>
                            <p class="text-gray-700">
                                如果没有其他线程争用锁，JVM会将锁标记为偏向锁，偏向锁的获取和释放不需要消耗任何竞争。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-teal-700">轻量级锁</h3>
                            <p class="text-gray-700">
                                当有其他线程尝试竞争时，JVM会升级为轻量级锁，这时线程会使用CAS（Compare And Swap）来尝试获得锁，锁竞争较少时不会进入阻塞。
                            </p>
                        </div>
                    </div>
                    
                    <div class="mb-6">
                        <h3 class="text-xl font-semibold mb-4 text-teal-700">重量级锁</h3>
                        <p class="text-gray-700">
                            如果有多个线程持续争用锁，JVM会将锁升级为重量级锁，并使用操作系统的互斥量（mutex）进行阻塞管理。
                        </p>
                    </div>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-6">
                        <pre class="text-gray-300 p-4 text-sm"><code>public class LockUpgradeExample {
    public synchronized void syncMethod() {
        // 执行时，锁会经历偏向锁 -> 轻量级锁 -> 重量级锁的过程
        System.out.println("Thread " + 
            Thread.currentThread().getName() + 
            " is executing.");
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-teal-50 rounded-lg p-4 border border-teal-200">
                        <p class="text-teal-800">
                            <i class="fas fa-lightbulb text-teal-600 mr-2"></i>
                            JVM首先尝试以偏向锁的形式获取锁，如果偏向锁无法满足需求，锁会升级为轻量级锁，然后再进一步升级为重量级锁。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-16" id="visualization">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-purple-600 text-white flex items-center justify-center mr-4">
                    <i class="fas fa-project-diagram"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁机制可视化</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden p-6">
                <h3 class="text-xl font-semibold mb-6 text-gray-800">锁升级过程</h3>
                
                <div class="mermaid">
                    graph LR
                        A[无锁状态] -->|第一个线程访问| B[偏向锁]
                        B -->|第二个线程竞争| C[轻量级锁]
                        C -->|多个线程竞争| D[重量级锁]
                        D -->|释放锁| A
                </div>
                
                <div class="mt-8">
                    <h3 class="text-xl font-semibold mb-6 text-gray-800">锁类型对比</h3>
                    <div class="mermaid">
                        mindmap
                            root((Java锁机制))
                                内置锁(synchronized)
                                    方法级锁
                                    代码块锁
                                    锁升级机制
                                       偏向锁
                                       轻量级锁
                                       重量级锁
                                ReentrantLock
                                    显式锁
                                    公平锁/非公平锁
                                    可中断锁
                                    条件变量
                                    可重入性
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 5: ReentrantLock -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-red-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">5</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">ReentrantLock的实现</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 rounded">ReentrantLock</code>是Java提供的另一种显式锁，它提供了比<code class="bg-gray-100 px-1 rounded">synchronized</code>更多的控制能力，如可中断、可重入、定时锁等。
                    </p>
                    
                    <p class="text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 rounded">ReentrantLock</code>的核心方法是<code class="bg-gray-100 px-1 rounded">lock()</code>和<code class="bg-gray-100 px-1 rounded">unlock()</code>。其内部实现了一个<code class="bg-gray-100 px-1 rounded">AbstractQueuedSynchronizer</code>（AQS）类，通过AQS来实现锁的队列管理和调度。
                    </p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-6">
                        <pre class="text-gray-300 p-4 text-sm"><code>public class ReentrantLockDemo {
    private final ReentrantLock lock = new ReentrantLock();

    public void methodWithLock() {
        lock.lock();  // 获取锁
        try {
            // 临界区代码
            System.out.println("Thread " + 
                Thread.currentThread().getName() + 
                " is executing.");
        } finally {
            lock.unlock();  // 释放锁
        }
    }
}</code></pre>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-red-700">lock()</h3>
                            <p class="text-gray-700">
                                尝试获取锁，如果锁被其他线程持有，当前线程会阻塞等待。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-red-700">unlock()</h3>
                            <p class="text-gray-700">
                                释放锁，唤醒等待队列中的其他线程。
                            </p>
                        </div>
                    </div>
                    
                    <div class="mt-6 p-4 bg-red-50 rounded-lg border border-red-200">
                        <h3 class="text-lg font-semibold mb-2 text-red-800">AQS机制</h3>
                        <p class="text-gray-700">
                            AQS管理线程的等待和唤醒机制，底层使用<code class="bg-gray-100 px-1 rounded">FIFO</code>队列来控制线程的执行顺序。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 6: Fairness -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-orange-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">6</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁的公平性</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 rounded">ReentrantLock</code>支持公平锁和非公平锁。公平锁保证了等待时间最长的线程先获取锁，而非公平锁则是先到先得，没有保证等待时间最久的线程先获取锁。
                    </p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-6">
                        <pre class="text-gray-300 p-4 text-sm"><code>public class FairLockDemo {
    private final ReentrantLock fairLock = 
        new ReentrantLock(true);  // 公平锁

    public void methodWithLock() {
        fairLock.lock();  // 获取锁
        try {
            System.out.println("Thread " + 
                Thread.currentThread().getName() + 
                " is executing.");
        } finally {
            fairLock.unlock();  // 释放锁
        }
    }
}</code></pre>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-orange-700">公平锁</h3>
                            <p class="text-gray-700">
                                通过构造<code class="bg-gray-100 px-1 rounded">ReentrantLock</code>时传入<code class="bg-gray-100 px-1 rounded">true</code>来启用公平锁，公平锁遵循先来先得的原则，避免了饥饿问题。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-orange-700">非公平锁</h3>
                            <p class="text-gray-700">
                                默认为非公平锁，线程不一定按照请求锁的顺序来执行。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 7: Interruptible -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-green-600 text-white flex items-center justify-center mr-4">
                    <span class="text-xl font-bold">7</span>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">锁的可中断性</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        <code class="bg-gray-100 px-1 rounded">ReentrantLock</code>提供了可中断的锁机制，即可以在等待锁时响应中断，避免了线程在锁争用时发生长时间阻塞的情况。
                    </p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-6">
                        <pre class="text-gray-300 p-4 text-sm"><code>public class InterruptibleLockDemo {
    private final ReentrantLock lock = new ReentrantLock();

    public void methodWithLock() throws InterruptedException {
        lock.lockInterruptibly();  // 可中断锁
        try {
            System.out.println("Thread " + 
                Thread.currentThread().getName() + 
                " is executing.");
        } finally {
            lock.unlock();  // 释放锁
        }
    }
}</code></pre>
                    </div>
                    
                    <div class="bg-green-50 rounded-lg p-4 border border-green-200">
                        <h3 class="text-lg font-semibold mb-2 text-green-800">lockInterruptibly()</h3>
                        <p class="text-gray-700">
                            获取锁时可以响应中断，若线程在等待锁的过程中被中断，它会抛出<code class="bg-gray-100 px-1 rounded">InterruptedException</code>，从而能够优雅地处理中断。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-16">
            <div class="bg-gradient-to-r from-purple-500 to-indigo-600 rounded-xl shadow-xl text-white p-8">
                <h2 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-star mr-3"></i>关键知识点总结
                </h2>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <h3 class="text-xl font-semibold mb-3">synchronized</h3>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>Java内置同步机制，使用简单</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>支持方法级和代码块级同步</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>内置锁升级机制优化性能</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-3">ReentrantLock</h3>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>功能更强大的显式锁</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>支持公平锁和非公平锁</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-300 mt-1 mr-2"></i>
                                <span>提供可中断的锁获取机制</span>
                            </li>
                        </ul>
                    </div>
                </div>
                
                <div class="mt-8">
                    <h3 class="text-xl font-semibold mb-4">选择建议</h3>
                    <div class="bg-white bg-opacity-10 p-4 rounded-lg">
                        <p>
                            <i class="fas fa-lightbulb mr-2"></i>
                            对于简单的同步需求，优先使用<code class="bg-purple-700 px-1 rounded">synchronized</code>；当需要更高级的功能（如可中断、公平锁等）时，考虑使用<code class="bg-purple-700 px-1 rounded">ReentrantLock</code>。
                        </p>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">深入技术细节，探索编程之美</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-purple-300 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm text-gray-500">
                © 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```